<script type="text/javascript" src="JO_JS/vadilation.js"></script>
<script>
	
	 $(document).ready(function() {
                    $(".datepicker").SO_start({
                        //changeYear:true

                    });

                    $(".datepicker").mask("99/99/9999", { placeholder: "_" });

                });

	</script>
<?php 
	
	$path="C:/xampp/htdocs/00_JO/JOi/controller/";
	include_once( $path."JO_artist_Controller.php" );
	
	
	
	?>
<script>
function kt()
{
if(document.getElementById("txt_choice").checked==false)
{

	document.getElementById("upanh").innerHTML="<input type='text'  id='txtimage' name='txtimage'  style='width:214px;color:#000'/>";
							 
}
else
{
	document.getElementById("upanh").innerHTML="<input type='file' id='txtimage' name='txtimage' style='width:214px;color:#000'/>";
}

}
 var musics=new Array();
 var n=0;

function FcheckFormTD(f){
//alert(document.getElementById('SO_amount').value);
//if(!FcheckFilled('type ',f.type.value)){ f.type.focus();return false; }
if(!FcheckFilled('subject ',document.getElementById('SO_subject').value)){ document.getElementById('SO_subject').focus();return false; }
if(!FcheckFilled('description ',f.SO_description.value)){ f.SO_description.focus();return false; }
if(!FcheckFilled('amount ',document.getElementById('SO_amount').value)){ document.getElementById('SO_amount').focus();return false; }
if(!FcheckNumber('amount',document.getElementById('SO_amount').value)){ document.getElementById('SO_amount').focus();return false; }
if(!FcheckFilled('start ',document.getElementById('SO_start').value)){document.getElementById('SO_start').focus();return false; }
if(!FcheckFilled('expired ',document.getElementById('SO_expired').value)){ document.getElementById('SO_expired').focus();return false; }
if(!FcheckFilled('note ',document.getElementById('SO_note').value)){ document.getElementById('SO_note').focus();return false; }

//if(!FcheckBoxes('Lĩnh vực',f.lbxlinhvuc,1,0)){f.lbxlinhvuc[0].focus();return false;}
//if(!FcheckFilled('Địa điểm làm việc',f.txtdiadiemlamviec.value)){ f.txtdiadiemlamviec.focus();return false; }
//if(!FcheckFilled('Mô tả sơ lược',f.txtmota.value)){ f.txtmota.focus();return false; }
//if(!FcheckFilled('kỹ năng công việc',f.txtkynang.value)){ f.txtkynang.focus();return false; }
//if(!FcheckFilled('mức lương',f.txtmucluong.value)){ f.txtmucluong.focus();return false; }
//if(!FcheckFilled('chế độ',f.txtchedo.value)){ f.txtchedo.focus();return false; }
//if(!FcheckFilled('yêu cầu hồ sơ',f.txthoso.value)){ f.txthoso.focus();return false; }
//if(!FcheckFilled('hạn nộp hồ sơ',f.txthannop.value)){ f.txthannop.focus();return false; }
//stemt.submit();
//stetc.submit();
return true;
}

	
	


function addtop(id){
        
        var contenttop="<span id='trtop_"+id+"'>";
        contenttop+="<table  class='JO_tablei_input' style='margin-left:8px;width:684px'>";
        contenttop+="<tr >";
		contenttop+="<input type='hidden' value='"+id+"' name='key[]'>"
		contenttop+="<td style='width: 28px' id='tdtopid_"+id+"'>"+id+"</td>";
        contenttop+="<td id='tdtop_"+id+"'width='612px' >"+document.getElementById("td_"+id).innerHTML+"</td>";
		contenttop+="<td style='width: 12px'><a href='#i' onclick='topup("+id+");'><img src='JO_images/JO_26_icon_top_on.png' class='JO_icon' alt='Up' title='Up'/></a></td>";
        contenttop+="<td style='width: 12px'><a href='#i' onclick='topdown("+id+");'><img src='JO_images/JO_28_icon_down_on.png' class='JO_icon' alt='Down' title='Down'/></a></td>";
        contenttop+="<td style='width: 12px'><a href='#i' onclick='removetop("+id+");'><img src='JO_images/JO_23_icon_delete_on.png' class='JO_icon' alt='Remove' title='Remove'/></a></td>";
        contenttop+="</tr>";
        contenttop+="</table>";
        contenttop+="</span>";
        document.getElementById("tb_top_music").innerHTML+=contenttop;

        //alert(document.getElementById("tb_top_music").innerHTML);
        var del = document.getElementById("tr_"+id);
        del.parentNode.removeChild(del);
        musics[n]=id;
        n++;
        //document.getElementById("kqkq").innerHTML=musics;
        create_top();
    }
    function removetop(id){
        
        var contentmusic="<span id='tr_"+id+"'>";
        contentmusic+="<table class='JO_tablei_input' style='margin-left:8px;width:684px' >";
        contentmusic+="<tr ><td id='td_"+id+"'>"+document.getElementById("tdtop_"+id).innerHTML+"</td>";
        contentmusic+="<td style='width:12px'><a href='#i' onclick='addtop("+id+");'><img src='JO_images/add_top.png' class='butt_image' alt='Add To Top Music' title='Add To Top Music'width='12px'/></a></td>";
        contentmusic+="</tr>";
        contentmusic+="</table>";
        contentmusic+="</span>";
        document.getElementById("tb_music").innerHTML+=contentmusic;
        var del=document.getElementById("trtop_"+id);
        del.parentNode.removeChild(del);
        for(var i=0;i<musics.length;i++){
            if(musics[i]==id){
                musics[i]=undefined;
                create_top();
                break;
            }
        }
        
    }
	    function topup(id){
			
        //alert(document.getElementById("trtop_"+id).id+":id");
        for(var i=0;i<musics.length;i++){
			
            if(musics[i]==id && i>0){
                var j=1;
                while(musics[i-j]==undefined && i-j>=0){
                    j++;
                }

                var contenttmp=document.getElementById("trtop_"+musics[i]).innerHTML;
				//  var contenttmp2=document.getElementById("trtop_"+musics[i-j]);
//                var pct=contenttmp.parentNode;
//                pct.replaceChild(contenttmp,contenttmp2);
//                pct.replaceChild(contenttmp2,contenttmp);
                document.getElementById("trtop_"+musics[i]).innerHTML=document.getElementById("trtop_"+musics[i-j]).innerHTML;;
                document.getElementById("trtop_"+musics[i-j]).innerHTML=contenttmp;

                var idtmptr=document.getElementById("trtop_"+musics[i]).id;
                var idtmptr2=document.getElementById("trtop_"+musics[i-j]).id;
                document.getElementById("trtop_"+musics[i]).id=document.getElementById("trtop_"+musics[i]).id+"abc123";
                document.getElementById("trtop_"+musics[i-j]).id=idtmptr;
                document.getElementById("trtop_"+musics[i]+"abc123").id=idtmptr2

                //hoan vi 2 element
                var tmp=musics[i];
                musics[i]=musics[i-j];
                musics[i-j]=tmp;

                //document.getElementById("kqkq").innerHTML=musics;
                create_top();
                //alert(musics);
                break;
            }
        }
        
    }
    function topdown(id){
	
        //alert(document.getElementById("trtop_"+id).id+":id");
        for(var i=0;i<musics.length;i++){
            if(musics[i]==id){
                var j=1;
                while(musics[i+j]==undefined && i+j<musics.length){

                    j++;
                }
                if(musics[i+j]==undefined){ return;}
                //alert(musics[i]+":"+musics[i+j]);
               
 

                var contenttmpdown=document.getElementById("trtop_"+musics[i]).innerHTML;
                document.getElementById("trtop_"+musics[i]).innerHTML=document.getElementById("trtop_"+musics[i+j]).innerHTML;
                document.getElementById("trtop_"+musics[i+j]).innerHTML=contenttmpdown;
                //alert(document.getElementById("trtop_"+musics[i+j]).id);

                var idtmptr=document.getElementById("trtop_"+musics[i]).id;
                var idtmptr2=document.getElementById("trtop_"+musics[i+j]).id;
                document.getElementById("trtop_"+musics[i]).id=document.getElementById("trtop_"+musics[i]).id+"abc123";
                document.getElementById("trtop_"+musics[i+j]).id=idtmptr;
                document.getElementById("trtop_"+musics[i]+"abc123").id=idtmptr2;
                
                //hoan vi 2 element
                var tmp=musics[i];
                musics[i]=musics[i+j];
                musics[i+j]=tmp;

                //document.getElementById("kqkq").innerHTML=musics;
                create_top();
                //alert(musics);
                break;
            }
        }

    }
	function create_top()
    {
        var ntop=1;
        for(var i=0;i<musics.length;i++){
            if(musics[i]!=undefined){
                document.getElementById("tdtopid_"+musics[i]).innerHTML=ntop;
                ntop++;
            }
        }
    }
	
	   function searchKeyPress(e,str)
    {
	
	
        // look for window.event in case event isn't passed in
        if (window.event) { e = window.event; }
        if (e.keyCode == 13)
        {
            

                location=("../JOi/index.php?JO_unit=012_recommendation&SO_chude=<?=$_GET['SO_chude']?>&SO_loai=<?=$_GET['SO_loai']?>&sea="+str);
            

        }
    }
	function searchKeyPress(e)
    {
        // look for window.event in case event isn't passed in
        if (window.event) { e = window.event; }
        if (e.keyCode == 13)
        {
            key=document.getElementById("txtsearchartist").value;
            if(key=="<?=$JO["JO_searchid"]?>" || key==""){

                location=("?JO_unit=013_Artist");
            }else{

                location=("?JO_unit=013_Artist&sea="+document.getElementById("txtsearchartist").value);
            }

        }
    }

</script>

<div style="width: 960px;background: url(JO_images/hr.gif1) repeat-x top left #222;position: relative;float:left;">
  <? include 'JO_013_nav.php';?>
  <div class="mar8i"></div>
  <div style="margin-left: 0px;" class="bar_720i" >
  <div style="" class="JO_h1i">
    K-PopZone
  </div>
  <div class="content720i">
    <div class="mar7i"></div>
    <div style="width: 704px;float: left;margin-bottom: 8px;">
      <div class="JO_Kpop_itemi JO_no_background">
        <div class="JO_kpop_item_titlei"> List Recommended </div>
        <div class="mar8i"></div>
        <table class="JO_tablei_input" width="680px">
        <form action="controller/JO_navigation.php" method="post">
        <?php
		if(isset($_GET['SO_chude']))
		$key=$_GET['SO_chude'];
		else
		$key=661;
		$result_artists=JO_13_get_artist_detail($key);
		if($result_artists->num_rows)
		$result_artist=$result_artists->fetch_array();
				 ?>
        
           
            <tr>
                <th style="width: 100px;">Tên Ca Sĩ</th>
                <td>
                    <input style="width: 214px;color:#000" type="text" name="txtname"
                           value="<?=$result_artist['name']?>"/>
                </td>
            </tr>
            <tr>
                <th>Tên Thật</th>
                <td>
                    <input style="width: 214px;color:#000" type="text" name="txtautonym"
                           value="<?=$result_artist['autonym']?>"/>
                </td>
            </tr>
            <tr>
                <th>Ngày Sinh</th>
                <td>
                    
                    
                    <input style="width: 214px;color:#000" type="text" name="txtbirth" class="datepicker"
                           value="<?=$result_artist['birth']?>"/>
                </td>
            </tr>
            <tr>
                <th>Giới Tính</th>
                <td>
                    <input type="radio" name="jo_sex" id="jo_sex" value="1" checked="checked" <?=(($result_artist["sex"]=="1")?"checked='checked'":"")?>>
                    <img src="JO_images/user_gray.png" />
                    <input type="radio" name="jo_sex" id="jo_sex" value="0" <?=(($result_artist["sex"]=="0")?"checked='checked'":"")?>>
                    <img src="JO_images/user_female.png" />
                    <input type="hidden"
                           value="<?=(isset($result_artist["sex"])?$result_artist["sex"]:"")?>"/>
                
                </td>
            </tr>
              <tr>
                <th>Quốc Gia</th>
                <td>
                    <select name="cbxnation" style="width: 218px;color:#000" class="icon-menu">
                        <option style="color:#000" value="KR" <?=((strtoupper($result_artist["nation"])=="KR")?"selected=1":"")?>>KR</option>
                        
                        <option value="VN" <?=((strtoupper($result_artist["nation"])=="VN")?"selected=1":"")?>
                                style="background: url(JO_80_image/JO_41_icon_nation/ad.png) no-repeat;padding-left: 30px;color:#000"
                                >VN</option>
                        <option style="color:#000" value="TJ" <?=((strtoupper($result_artist["nation"])=="TJ")?"selected=1":"")?>>TJ</option>
                        <option style="color:#000" value="TK" <?=((strtoupper($result_artist["nation"])=="TK")?"selected=1":"")?>>TK</option>
                        <option style="color:#000" value="TL" <?=((strtoupper($result_artist["nation"])=="TL")?"selected=1":"")?>>TL</option>
                        <option style="color:#000" value="TM" <?=((strtoupper($result_artist["nation"])=="TM")?"selected=1":"")?>>TM</option>
                        <option style="color:#000" value="TN" <?=((strtoupper($result_artist["nation"])=="TN")?"selected=1":"")?>>TN</option>
                        <option style="color:#000" value="TO" <?=((strtoupper($result_artist["nation"])=="TO")?"selected=1":"")?>>TO</option>
                        <option style="color:#000" value="TR" <?=((strtoupper($result_artist["nation"])=="TR")?"selected=1":"")?>>TR</option>
                        <option style="color:#000" value="TT" <?=((strtoupper($result_artist["nation"])=="TT")?"selected=1":"")?>>TT</option>
                        <option style="color:#000" value="TV" <?=((strtoupper($result_artist["nation"])=="TV")?"selected=1":"")?>>TV</option>
                        <option style="color:#000" value="TW" <?=((strtoupper($result_artist["nation"])=="TW")?"selected=1":"")?>>TW</option>
                        <option style="color:#000" value="TZ" <?=((strtoupper($result_artist["nation"])=="TZ")?"selected=1":"")?>>TZ</option>
                        <option style="color:#000" value="UA" <?=((strtoupper($result_artist["nation"])=="UA")?"selected=1":"")?>>UA</option>
                        <option style="color:#000" value="UG" <?=((strtoupper($result_artist["nation"])=="UG")?"selected=1":"")?>>UG</option>
                        <option style="color:#000" value="US" <?=((strtoupper($result_artist["nation"])=="US")?"selected=1":"")?>>US</option>
                        <option style="color:#000" value="UM" <?=((strtoupper($result_artist["nation"])=="UM")?"selected=1":"")?>>UM</option>
                        <option style="color:#000" value="UY" <?=((strtoupper($result_artist["nation"])=="UY")?"selected=1":"")?>>UY</option>
                        <option style="color:#000" value="UZ" <?=((strtoupper($result_artist["nation"])=="UZ")?"selected=1":"")?>>UZ</option>
                        <option style="color:#000" value="VA" <?=((strtoupper($result_artist["nation"])=="VA")?"selected=1":"")?>>VA</option>
                        <option style="color:#000" value="VC" <?=((strtoupper($result_artist["nation"])=="VC")?"selected=1":"")?>>VC</option>
                        <option style="color:#000" value="VE" <?=((strtoupper($result_artist["nation"])=="VE")?"selected=1":"")?>>VE</option>
                        <option style="color:#000" value="VG" <?=((strtoupper($result_artist["nation"])=="VG")?"selected=1":"")?>>VG</option>
                        <option style="color:#000" value="VI" <?=((strtoupper($result_artist["nation"])=="VI")?"selected=1":"")?>>VI</option>
                        <option style="color:#000" value="VU" <?=((strtoupper($result_artist["nation"])=="VU")?"selected=1":"")?>>VU</option>
                        <option style="color:#000" value="WALES" <?=((strtoupper($result_artist["nation"])=="WALES")?"selected=1":"")?>>WALES</option>
                        <option style="color:#000" value="WF" <?=((strtoupper($result_artist["nation"])=="WF")?"selected=1":"")?>>WF</option>
                        <option style="color:#000" value="WS" <?=((strtoupper($result_artist["nation"])=="WS")?"selected=1":"")?>>WS</option>
                        <option style="color:#000" value="YE" <?=((strtoupper($result_artist["nation"])=="YE")?"selected=1":"")?>>YE</option>
                        <option style="color:#000" value="YT" <?=((strtoupper($result_artist["nation"])=="YT")?"selected=1":"")?>>YT</option>
                        <option style="color:#000" value="ZA" <?=((strtoupper($result_artist["nation"])=="ZA")?"selected=1":"")?>>ZA</option>
                        <option style="color:#000" value="ZM" <?=((strtoupper($result_artist["nation"])=="ZM")?"selected=1":"")?>>ZM</option>
                        <option style="color:#000" value="ZW" <?=((strtoupper($result_artist["nation"])=="ZW")?"selected=1":"")?>>ZW</option>
                    </select>
            
                </td>
            </tr>
            <tr>
                <th>Công Ty</th>
                <td>
                    <select name="cbxorganization" style="width: 218px;color:#000">
                        <?
						if(isset($_GET['SO_chude']))
                        $result_organs=JO_13_get_organization();
						if($result_organs->num_rows)
						while($result_organ=$result_organs->fetch_array())
						{
                            ?>
                        <option  style="color:#000" value="<?=$result_organ["key"]?>" <?=(($result_organ["key"]==$result_artist["organization"])?"selected='selected'":"")?>><?=$result_organ["name"]?></option>
                            <?

                        }

                        ?>

                    </select>
                </td>
            </tr>
            <tr>
                <th>Mô Tả</th>
                <td>
                    <textarea name="txtcontent" style="width: 214px;color:#000"><?=(isset($result_artist["content"])?$result_artist["content"]:"")?></textarea>
                </td>
            </tr>
            <tr class="nohover">
                <th></th>
                <td>
                	<input type="hidden" name="JO_controller" id="JO_controller"  value="JO_artist_Controller" />
                	<input type="hidden" name="JO_query" value="JO_artist_update" />
                    <input type="hidden" name="JO_chude" id="JO_chude" value="<?=(isset($_GET['SO_chude']))?$_GET['SO_chude']:""?>" />
       	            <input type="submit" class="JO_button" value="Update" style="width: 218px;color:#000"/>
                </td>
            </tr>
            </form>
        </table>
      </div>
      <div class="JO_Kpop_itemi JO_no_background">
        <div class="JO_kpop_item_titlei"><div style="width:114px;float:left">Hình ảnh</div><div style="float:left;width:500px">Đường dẫn</div><div style="float:left">#</div> </div>
        <div class="mar8i"></div>
        <table class="JO_tablei_input" width="680px">
       	<tr>
        <td style="border:none">
        <form action="controller/JO_navigation.php" method="post" enctype="multipart/form-data">
        <div style="width:114px;float:left"><input type="checkbox" id="txt_choice"  onclick = "kt()"/>Upload</div>
        <div style="float:left;width:488px" id="upanh"><input type="text" id="txtimage" name='txtimage' style="width:218px;color:#000"/></div>
       				 <input type="hidden" name="JO_controller" id="JO_controller"  value="JO_artist_Controller" />
                	<input type="hidden" name="JO_query" value="JO_artist_image" />
                    <input type="hidden" name="JO_chude" id="JO_chude" value="<?=isset($_GET['SO_chude'])?$_GET['SO_chude']:""?>" />
        <div style="float:left"><input type="submit" value="ADD"  style="color:#000"/></div>
        </form>
        </td>
        </tr>
        </table>
      </div>
    </div>
  </div>
</div>
<div id ="kqkq"></div>
